home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / gfx / x11 / xlincity098.lha / README.profiling < prev    next >
Text File  |  2004-10-20  |  2KB  |  53 lines

  1.     ================     =================
  2.     README.profiling     part of Lin-city.
  3.     ================     =================
  4.  
  5. I have only profiled this program when running with SVGALib.
  6. (If you what to profile under X, you're on your own.)
  7.  
  8. If you are using svgalib 1.2.9 or greater (as you should), then you will
  9. need to edit .../svgalibxxx/src/vga.c and stop svgalib catching the profile
  10. signal. The code should now look like this:-
  11.  
  12. /* We invoke the old interrupt handler after setting text mode */
  13. /* We catch all signals that cause an exit by default (aka almost all) */
  14. static char sig2catch[] =
  15. {SIGHUP, SIGINT, SIGQUIT, SIGILL,
  16.  SIGTRAP, SIGIOT, SIGBUS, SIGFPE,
  17.  SIGSEGV, SIGPIPE, SIGALRM, SIGTERM,
  18.  SIGXCPU, SIGXFSZ, SIGVTALRM,
  19.  /* SIGPROF, */ SIGPWR};
  20. static struct sigaction old_signal_handler[sizeof(sig2catch)];
  21.  
  22.     NOTE the comments around SIGPROF.
  23.  
  24. Now recompile svgalib with make install but READ THE SVGALIB DOCS YOURSELF
  25. just in case.
  26.  
  27. To enable profiling, uncomment the PROFx vars in the makefile.
  28.  
  29. To disable profiling, comment the PROFx vars in the makefile.
  30.  
  31. Then just run the program as usual.
  32.  
  33. When you exit, put the profiling info in a file:
  34.  
  35.     gprof /usr/local/bin/lincity > proffile.txt
  36.  
  37. (The raw profiling info is stored in gmon.out, a binary.)
  38.  
  39. Note:
  40.     I have pushed the gl_setpixel() etc. routines through another
  41.     function when profiling is enabled. It will slow things down 
  42.     a bit (<1%), but if you want to see how many times these routines 
  43.     are called, you'll have to put up with it. Not all the gl_routines
  44.     are redirected in this way, only the ones called during the main
  45.     body of the code. These routines are identified by the FP in front
  46.     of the 'old' function name, ie the above becomes FPgl_setpixel().
  47.     (Perhaps not the best choice of prefix for obvious reasons, but
  48.     it stands for Floyd's Profiling.) You can disable this part alone
  49.     by commenting out the 'PROFD = -DCS_PROFILE' line.
  50.  
  51.  
  52.  
  53.